#include <stdio.h>
#include <string.h>
#include <errno.h>

struct S
{
    char arr[10];
    int age;
    float score;
};

int main()
{
    struct S s = {"zhangsan", 25, 50.5f};
    
    FILE* pf = fopen("test.txt", "w");
    if(pf == NULL)
    {
        perror("fopen");
        return 1;
    }

    fprintf(pf, "%s %d %f", s.arr, s.age, s.score);//写入文件//printf输出到运行框，fprintf输出到文件中（以程序的视角定义输入输出）

    //关闭文件
    fclose(pf);
    pf = NULL;
    return 0;
}